//
//  LayoutCommen.swift
//  Cheetah
//
//  Created by qurongxiang on 2018/9/3.
//  Copyright © 2018年 zhaowang. All rights reserved.
//  布局配置

import UIKit

struct LayoutCommon {
    
    /// 宽度
    static let width = UIScreen.main.bounds.size.width
    
    /// 高度
    static let height = UIScreen.main.bounds.size.height
    
    /// 导航栏边距
    static let navHeight:CGFloat = LayoutCommon.isBangs() ? 88 : 64
    
    /// tabbar边距
    static let tabarHeight:CGFloat = LayoutCommon.isBangs() ? 83 : 49
    
    /// 底部边距
    static let bottomMargin:CGFloat = LayoutCommon.isBangs() ? 34 : 0
    
    /// 真实高度
    static let realHeight:CGFloat =  LayoutCommon.height - LayoutCommon.navHeight -  LayoutCommon.bottomMargin
    
    /// 判断齐刘海
    ///
    /// - Returns: 齐刘海结果
    static func isBangs() -> Bool {
        guard #available(iOS 11.0, *) else {
            return false
        }
        
        if #available(iOS 12.0, *) {
            if UIApplication.shared.windows[0].safeAreaInsets ==  UIEdgeInsets(top: 20, left: 0, bottom: 0, right: 0) {
                return false
            }else {
                return true
            }
        }
        
        if (UIApplication.shared.windows[0].safeAreaInsets != UIEdgeInsets.zero) {
            return true
        }else {
            return false
        }
    }
}
